package com.zhiyin.seal.service.impl;

import com.zhiyin.seal.dao.NoticeDao;
import com.zhiyin.seal.entity.NoticeEntity;
import com.zhiyin.seal.entity.bo.NoticeBo;
import com.zhiyin.seal.service.NoticeService;
import com.zhiyin.seal.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    NoticeDao noticeDao;

    @Override
    public Boolean publishNotice(NoticeBo noticeBo) {
        return noticeDao.insertNotice(BeanUtil.copy(noticeBo, NoticeEntity.class)) > 0;
    }

    @Override
    public List<NoticeBo> getNoticeList(Long companyId) {
        return BeanUtil.copyList(noticeDao.selectNoticeList(companyId),NoticeBo.class);
    }

    @Override
    public NoticeBo getNoticeDetail(Long id) {
        return BeanUtil.copy(noticeDao.selectNoticeDetail(id),NoticeBo.class);
    }

    @Override
    public Boolean modifyNotice(NoticeBo noticeBo) {
        return noticeDao.updateNotice(BeanUtil.copy(noticeBo,NoticeEntity.class)) > 0;
    }

    @Override
    public Boolean deleteNotice(Long id) {
        return noticeDao.deleteNotice(id) > 0;
    }

    @Override
    public Boolean updateDisplay(NoticeBo noticeBo) {
        return noticeDao.updateDisplay(BeanUtil.copy(noticeBo,NoticeEntity.class)) > 0;
    }
}
